﻿using System;
using LuaInterface;

namespace MyAnt.Core
{
    public class PocLuaScriptableClass : ILuaScriptable
    {
        private Lua _lua;

        public String StringValue { get; private set; }

        public PocLuaScriptableClass()
        {
            _lua = new Lua();
            _lua.RegisterFunction("TestSetString", this, this.GetType().GetMethod("TestSetStringCSharp"));
            _lua.RegisterFunction("TestGetString", this, this.GetType().GetMethod("TestGetStringCSharp"));

            StringValue = "hello";
        }
        
        public void TestSetStringCSharp(String newStringValue)
        {
            StringValue = newStringValue;
        }

        public String TestGetStringCSharp()
        {
            return StringValue;
        }

        public void Dispose()
        {
            _lua = null;
        }

        public Lua Lua
        {
            get { return _lua; }
        }
    }
}
